package com.collect.cameroon.zhiScene.zhiCollection.zhiBonusRules;

import android.annotation.SuppressLint;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.collect.cameroon.R;
import com.collect.cameroon.zhiBase.BaseActivity;
import com.collect.cameroon.zhiGlobal.zhiAppSettings.ZHIProjectRouter;
import com.collect.cameroon.zhiScene.zhiWidget.zhiNavigationBar.ZHINavigationBar;

import butterknife.BindView;

@SuppressLint("NonConstantResourceId")
@Route(path = ZHIProjectRouter.ZHI_PERFORMANCE_COLLECTION_BONUS_RULES)
public class ZHICollectionBonusRulesActivity extends BaseActivity {

    @BindView(R.id.navigationBar)
    ZHINavigationBar navigationBar;

    @BindView(R.id.tv_rule1_des0)
    TextView tv_rule1_des0;
    @BindView(R.id.tv_rule1_des1)
    TextView tv_rule1_des1;
    @BindView(R.id.tv_rule1_des2)
    TextView tv_rule1_des2;

    @BindView(R.id.tv_rule2_des0)
    TextView tv_rule2_des0;
    @BindView(R.id.tv_rule2_des1)
    TextView tv_rule2_des1;
    @BindView(R.id.tv_rule2_des2)
    TextView tv_rule2_des2;

    @BindView(R.id.tv_rule3_des0)
    TextView tv_rule3_des0;
    @BindView(R.id.tv_rule3_des1)
    TextView tv_rule3_des1;
    @BindView(R.id.tv_rule3_des2)
    TextView tv_rule3_des2;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_collection_bonus_rules;
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initView() {
        try {
            navigationBar.showLeft().hideRight().setCenterText(getString(R.string.page_bonus_rules)).setBarClickListener(new ZHINavigationBar.OnNavigationBarClickListener() {
                @Override
                public void onNavigationBarLeftClick(View v) {
                    finish();
                }

                @Override
                public void onNavigationBarRightClick(View v) {
                }
            });

            String b1CaseNum = "100";
            String b1CollectedNum = "300";
            String b1Rewarded = "200F per order.";
            String b1Calute = "(300-100)*200=40000.";

            String b1Des0FullString = getString(R.string.rule1_des0) + b1CaseNum + getString(R.string.rule1_des01);
            SpannableStringBuilder b1Builder0 = new SpannableStringBuilder(b1Des0FullString);
            b1Builder0.setSpan(new StyleSpan(Typeface.BOLD), getString(R.string.rule1_des0).length(), getString(R.string.rule1_des0).length() + b1CaseNum.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            tv_rule1_des0.setText(b1Builder0);

            String b1Des1String0 = (getString(R.string.rule1_des1) + " " + b1CaseNum + " " + getString(R.string.rule1_des10) + " ");
            String b1Des1FullString = b1Des1String0 + b1Rewarded;
            SpannableStringBuilder b1Builder1 = new SpannableStringBuilder(b1Des1FullString);
            b1Builder1.setSpan(new StyleSpan(Typeface.BOLD), b1Des1String0.length(), b1Des1FullString.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            b1Builder1.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.theme_green_0)), b1Des1String0.length(), b1Des1FullString.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            tv_rule1_des1.setText(b1Builder1);

            String b1Des2String0 = (getString(R.string.rule1_des2) + " " + b1CollectedNum + " " + getString(R.string.rule1_des20) + "\n");
            String b1Des2FullString = b1Des2String0 + b1Calute;
            SpannableStringBuilder b1Builder2 = new SpannableStringBuilder(b1Des2FullString);
            b1Builder2.setSpan(new StyleSpan(Typeface.BOLD), b1Des2String0.length(), b1Des2FullString.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            tv_rule1_des2.setText(b1Builder2);

            //////////////////////
            String b2CaseNum = "40";
            String b2CollectedNum = "100";
            String b2Rewarded = "500F per order.";
            String b2Calute = "(100-40)*500=30000.";

            String b2Des0FullString = getString(R.string.rule2_des0) + b2CaseNum + getString(R.string.rule2_des01);
            SpannableStringBuilder b2Builder0 = new SpannableStringBuilder(b2Des0FullString);
            b2Builder0.setSpan(new StyleSpan(Typeface.BOLD), getString(R.string.rule2_des0).length(), getString(R.string.rule2_des0).length() + b2CaseNum.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            tv_rule2_des0.setText(b2Builder0);

            String b2Des1String0 = (getString(R.string.rule2_des1) + " " + b2CaseNum + " " + getString(R.string.rule2_des10) + " ");
            String b2Des1FullString = b2Des1String0 + b2Rewarded;
            SpannableStringBuilder b2Builder1 = new SpannableStringBuilder(b2Des1FullString);
            b2Builder1.setSpan(new StyleSpan(Typeface.BOLD), b2Des1String0.length(), b2Des1FullString.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            b2Builder1.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.theme_green_0)), b2Des1String0.length(), b2Des1FullString.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            tv_rule2_des1.setText(b2Builder1);

            String b2Des2String0 = (getString(R.string.rule2_des2) + " " + b2CollectedNum + " " + getString(R.string.rule2_des20) + "\n");
            String b2Des2FullString = b2Des2String0 + b2Calute;
            SpannableStringBuilder b2Builder2 = new SpannableStringBuilder(b2Des2FullString);
            b2Builder2.setSpan(new StyleSpan(Typeface.BOLD), b2Des2String0.length(), b2Des2FullString.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            tv_rule2_des2.setText(b2Builder2);

            //////////////////////
            String b3CaseNum = "200,000";
            String b3CollectedNum = "600,000";
            String b3Rewarded0 = "10,000F.";
            String b3Rewarded = "10% per order.";
            String b3Calute = "10000+(600000-200000)*10%=50000.";

            String b3Des0String0 = getString(R.string.rule3_des0) + b3CaseNum + " " + getString(R.string.rule3_des01) + " ";
            String b3Des0FullString = b3Des0String0 + b3Rewarded0;
            SpannableStringBuilder b3Builder0 = new SpannableStringBuilder(b3Des0FullString);
            b3Builder0.setSpan(new StyleSpan(Typeface.BOLD), getString(R.string.rule3_des0).length(), getString(R.string.rule3_des0).length() + b3CaseNum.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            b3Builder0.setSpan(new StyleSpan(Typeface.BOLD), b3Des0String0.length(), b3Des0FullString.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            b3Builder0.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.theme_green_0)), b3Des0String0.length(), b3Des0FullString.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            tv_rule3_des0.setText(b3Builder0);

            String b3Des1String0 = (getString(R.string.rule3_des1) + " " + b3CaseNum + " " + getString(R.string.rule3_des10) + " ");
            String b3Des1FullString = b3Des1String0 + b3Rewarded;
            SpannableStringBuilder b3Builder1 = new SpannableStringBuilder(b3Des1FullString);
            b3Builder1.setSpan(new StyleSpan(Typeface.BOLD), b3Des1String0.length(), b3Des1FullString.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            b3Builder1.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.theme_green_0)), b3Des1String0.length(), b3Des1FullString.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            tv_rule3_des1.setText(b3Builder1);

            String b3Des2String0 = (getString(R.string.rule3_des2) + " " + b3CollectedNum + " " + getString(R.string.rule3_des20) + "\n");
            String b3Des2FullString = b3Des2String0 + b3Calute;
            SpannableStringBuilder b3Builder2 = new SpannableStringBuilder(b3Des2FullString);
            b3Builder2.setSpan(new StyleSpan(Typeface.BOLD), b3Des2String0.length(), b3Des2FullString.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            tv_rule3_des2.setText(b3Builder2);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
